import React,{useState,useEffect} from "react";
// import {} from './style'
import CitySelect from './Cityselect'
import { useSearchParams } from "react-router-dom";
import { getBanners } from '@/api/request'
import { getRestaurants } from "@/api/request";
import Banners from './Banners'
import SetMeal from './SetMeal'
import StoreList from './StoreList'
import StoreInfo from "./StoreInfo";
const Home =()=>{

    const [search]=useSearchParams()
    const cityName=search.get('name') || ''
    const [banners,setBanners]=useState([])
    const [restaurants,setRestaurants]=useState([])

    useEffect(()=>{
        (async ()=>{
            let {data}=await getBanners()
            let {data:resData}=await getRestaurants()
            setBanners(data)
            setRestaurants(resData)
            console.log(restaurants);
        })()
    },[])


    return(
        <div>
            <CitySelect cityName={cityName}/>
            {/* Banners业务 */}
            <Banners banners={banners}/>
            {/* 单纯切页面 把页面展示完成，但功能不展开*/}
            <SetMeal/>
            <StoreList />
            <StoreInfo restaurants={restaurants}/>

        </div>
    )
}
export default Home